<include file="Public/header" />
<title>管理员列表</title>
</head>
<body>
<div class="pd-20" style="margin-top:-20px;">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<form class="formleft" name="" id="" action="__URL__/add_orderdetail/" method="get">
			<input type="hidden" value="<{:I('manua_id')}>" name="manua_id">
			<input type="hidden" value="<{:I('warehouse_code')}>" name="warehouse_code">
			<input type="hidden" value="<{:I('username')}>" name="username">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['goods_no']}>" placeholder="商品编码" name="goods_no">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['goods_name']}>" placeholder="商品名称" name="goods_name">
			<input class="input-text" style="width:200px" type="text" value="<{$_GET['goods_brand']}>" placeholder="品牌" name="goods_brand">
			<button type="submit" class="btn btn-success"><i class="icon-plus"></i> 查询</button>
		</form>
		<span class="r">共有数据：<strong><{$total}></strong> 条</span> 
    </div>
	
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="15">商品库存列表</th>
			</tr>
			<tr class="text-c">
				<th width="25" class="sorting_disabled" rowspan="1" colspan="1" aria-label="" style="width: 25px;">
					<input type="checkbox" name="" value="">
				</th>
				<th width="25">序号</th>
				<th width="">商品编码</th>
				<th width="">账册编号</th>
				<th width="">商品名称</th>
				<th width="">条形码</th>
				<th width="">单位</th>
				<th width="">入库平均价格</th>
				<th width="">总数量</th>
				<th width="">库存数量</th>
				<th width="">合格品</th>
				<th width="">残次品</th>
				<th width="">报废品</th>
			</tr>
		</thead>
		<tbody class="tbody">
			<volist name="list" id="vo">
			<tr class="text-c">
				<td><input type="checkbox" value="<{$vo.id}>" name="" class="ids"></td>
				<td><{$i}></td>
				<td><{$vo.goods_no}></td>
				<td><{$vo.manua_id}></td>
				<td><{$vo.goods_name}></td>
				<td><{$vo.bar_code}></td>
				<td><{$vo.unit1}></td>
				<td>
				<{:round($vo['goods_price'],2)}>(<empty name="vo.current_type">人民币<else /><{$vo.current_type}></empty>)
				</td>
				<td><{$vo.amount}>(<{$vo.unit1}>)</td>
				<td><{$vo.storage_amount}>(<{$vo.unit1}>)</td>
				<td><{$vo.conforming_p}>(<{$vo.unit1}>)</td>
				<td><{$vo.nonconforming_p}>(<{$vo.unit1}>)</td>
				<td><{$vo.scrap_one}>(<{$vo.unit1}>)</td>
			</tr>
			</volist>			
		</tbody>
	</table>
	<div class="page mt" style="text-align:right">
		<{$page}>
		<button type="submit" onclick="add()" class="btn btn-success"><i class="icon-plus"></i> 添加</button>
	</div>
</div>

<div class="pd-20" style="margin-top:-20px;">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="r">共有数据：<strong><{:count($goodslist)}></strong> 条</span> 
    </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="15">待添加商品列表</th>
			</tr>
			<tr class="text-c">
				<th width="25">序号</th>
				<th width="">商品编码</th>
				<th width="">商品名称</th>
				<th width="">条形码</th>
				<th width="">价格</th>
				<th width="">数量</th>
				<th width=""></th>
			</tr>
		</thead>
		<tbody class="tbody2">
			<volist name="goodslist" id="vo">
			<tr class="text-c">
				<td><{$i}></td>
				<td><{$vo.goods_no}></td>
				<td><{$vo.goods_name}></td>
				<td><{$vo.bar_code}></td>
				<td>
					<{:round($vo['goods_price'],2)}>
				</td>
				<td><input type="text" value="" class="input-text" style="width:50px;"></td>
				<td>
					<a title="删除" href="javascript:;" onclick="admin_del('__URL__/del_orderdetail/','<{$i}>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a>
				</td>
			</tr>
			</volist>			
		</tbody>
	</table>
	<div class="page mt" style="text-align:right">
		<button type="button" onclick="confirm()" class="btn btn-success"><i class="icon-plus"></i> 确定</button>
	</div>
</div>
<script>
	function confirm(){
		var tr=$('.tbody2 tr');
		var goods_nums="";
        for(var i=0;i<tr.length;i++){
			td=tr.eq(i).find('td');
			goods_nums+=","+td.eq(5).find('input').val();
			if(td.eq(5).find('input').val()==""){
				layer.msg("数量不能为空");
				return false;
			}
		}
		goods_nums=goods_nums.substring(1);
		$.ajax({
			type: 'POST',
			data: {goods_nums:goods_nums,warehouse_code:"<{:I('warehouse_code')}>"},
			url: "<{:U('add_order_list')}>",
			success:function(data){
				window.location.href="<{:U('add_order_list',array('warehouse_code'=>I('warehouse_code')))}>";
			}
		})
	}
	function add(){
		var tr=$('.tbody tr');
		var option = $(".ids");
		var checked_counts=0;
		var goods_no="";
		var goods_name="";
		var goods_price="";
		var bar_code="";
        for(var i=0;i<option.length;i++){
			if(option[i].checked){
				td=tr.eq(i).find('td');
				checked_counts++;
				goods_no+=","+td.eq(2).text();
				goods_name+=","+td.eq(4).text();
				goods_price+=","+td.eq(7).text();
				bar_code+=","+td.eq(5).text();
			}
		}
		goods_no=goods_no.substring(1);
		goods_name=goods_name.substring(1);
		goods_price=goods_price.substring(1);
		bar_code=bar_code.substring(1);
		
		if(checked_counts==0){
			layer.msg('请选择内容');
			return false;
		}else{
			$.ajax({
				type: 'POST',
				data: {goods_no:goods_no,goods_name:goods_name,goods_price:goods_price,bar_code:bar_code},
				url: "<{:U('adds_orderdetail')}>",
				success:function(data){
					layer.msg(data.message);
					if(data.status==0){
						return false;
					}
					window.location.href=window.location.href;
				}
			})
		}
	}
</script>
<include file="Public/footer" />
<include file="Public/footer_js" />
</body>
</html>